package com.example.controller.admin;

import com.example.base.ResultBaseController;
import com.example.entity.ExamStore;
import com.example.entity.Store;
import com.example.service.StoreService;
import com.example.vo.Result;
import com.example.vo.comment.PageResult;
import io.swagger.v3.oas.annotations.Operation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description:
 * @Author: aimi
 * @Create: 2024-05-31
 **/
@RestController
@RequestMapping("/admin/store/")
@Slf4j
public class AdminStoreController extends ResultBaseController<StoreService, Store> {
    @Autowired
    private StoreService storeService;

    @PostMapping("/downAllGoods/{storeId}")
    public Result downAllGoods(@PathVariable Long storeId){
        storeService.downAllGoods(storeId);
        return Result.ok();
    }

    @GetMapping("/getExamStoreList")
    @Operation(summary = "获取待审核店铺列表")
    public Result<PageResult<ExamStore>> getExamStoreList(@RequestParam(defaultValue = "1") Integer pageNo,
                                               @RequestParam(defaultValue = "10") Integer pageSize,
                                               @RequestParam(defaultValue = "0") Integer status){
        log.info("获取待审核店铺列表：pageNo:{},pageSize:{},status:{}",pageNo,pageSize,status);
        PageResult<ExamStore> pageResult = storeService.getExamStoreList(pageNo,pageSize,status);
        return Result.ok(pageResult);
    }

    @PostMapping("/examStore/{examId}")
    @Operation(summary = "通过 / 不通过店铺申请")
    public Result examStore(@PathVariable Long examId,Integer status){
        log.info("进行店铺审核：examId:{}，status:{}",examId,status);
        storeService.examStatus(examId,status);
        return Result.ok();
    }
}